package com.noble.glamour.ui.fragment.video;

import android.app.Activity;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.noble.glamour.R;
import com.noble.glamour.module.logic.application.App;
import com.noble.glamour.module.logic.application.ModuleMgr;
import com.noble.glamour.module.util.UIShow;
import com.noble.glamour.third.recyclerholder.BaseRecyclerViewAdapter;
import com.noble.glamour.third.recyclerholder.BaseRecyclerViewHolder;
import com.noble.library.utils.ScreenUtils;

/**
 * 管理视频集
 * Created by Su on 2017/11/14.
 */
public class VideoMgrAdapter extends BaseRecyclerViewAdapter<String> {
    private Activity activity;
    private int params;   // item宽高

    public VideoMgrAdapter(Activity activity) {
        this.activity = activity;
        int horizontalSpacing = ScreenUtils.getScreenWidth(activity) / 30;
        params = (ScreenUtils.getScreenWidth(activity) - 4 * horizontalSpacing) / 2;
    }

    @Override
    public int[] getItemLayouts() {
        return new int[]{R.layout.video_manager};
    }

    @Override
    public void onBindRecycleViewHolder(BaseRecyclerViewHolder viewHolder, int position) {
        String data = getItem(position);

        ImageView img_preview = viewHolder.findViewById(R.id.video_preview);
        img_preview.setLayoutParams(new RelativeLayout.LayoutParams(params, params));

        img_preview.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UIShow.showPLManagerActivity(activity, "/storage/emulated/0/yanyuan/ShortVideo/edited.mp4");
            }
        });
    }

    @Override
    public int getRecycleViewItemType(int position) {
        return 0;
    }
}
